<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="Content-Script-Type" content="text/javascript" />
		<meta http-equiv="Content-Style-Type" content="text/css" />
		<title>コントロールパネル</title>
		<link rel="stylesheet" href="./assets/styles/default.css" type="text/css" />
		<script src="assets/scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
		<script src="assets/scripts/menu.js" type="text/javascript"></script>
		<script src="assets/scripts/table.js" type="text/javascript"></script>
		<link type="text/css" href="./assets/styles/ui-lightness/jquery-ui-1.7.2.custom.css" rel="stylesheet" />
		<script type="text/javascript" src="./assets/scripts/ui/ui.core.js"></script>
		<script type="text/javascript" src="./assets/scripts/ui/ui.datepicker.js"></script>
		<script type="text/javascript">
		$(function() {
			$('.message').fadeIn("slow");
			$('.text_date').datepicker({
				changeMonth: true,
				changeYear: true,
				dateFormat: 'yy/mm/dd'
			});

			$('#btn-export').click(function(){
				if(confirm('ダウンロードしますか？')){
					document.form1.csv.value="download";
					document.form1.submit();
				}
			});
			$('#btn-reset').click(function(){
				location.href = document.form1.action;
			});

			$('#btn-map-add').click(function(){
				if ( chkWeek() ) {
					document.form1.action = "mmapg_form.php";
					document.form1.submit();
				}
			});

			$('#btn-map-copy').click(function(){
				//var mapno = document.form1.map_no.value;
				//if (mapno.length == 0){
				//alert("マップNOを入力してください");
				//return false;
				//}
				if ( chkWeek() && chkWeekto()  ) {
					document.form1.mapoperflg.value="copy";
					document.form1.submit();

				}
			});
			$('#btn-no-del').click(function(){
				if(confirm('情報を削除しますよろしいですか？')){
					var mapno = document.form1.map_no_del.value;
					if (mapno.length == 0){
						alert("削除したいマップNOを入力してください");
						return false;
					 }
					if ( chkWeek() ) {
						document.form1.mapoperflg.value="nodel";
						document.form1.submit();

					}
				}
			});

			$('#btn-sort-del').click(function(){
				if(confirm('情報を削除しますよろしいですか？')){
				var mapno = $("#sort_del").val() ;
					if (mapno.length == 0){
						alert("削除したい区分を選択してください");
						return false;
					 }
					if ( chkWeek() ) {
						document.form1.mapoperflg.value="sortdel";
						document.form1.submit();
					}
				}
			});

			$('#btn_search').click(function(){
				if ( chkWeek() ) {
					document.form1.csv.value="";
					document.form1.submit();
				}
			});
			$('#year4').change(function(){
				var year4 = this.value;
				var myDate = new Date();
				var nowtime =  myDate.getTime();

				$.get("mmap_week_ajax.php",{ y: year4,t : nowtime }, function(data){
					$("#week_cd").children().remove();
					$("#week_cd").append( data );
				});
			});
			$('#year4to').change(function(){
				var year4 = this.value;
				var myDate = new Date();
				var nowtime =  myDate.getTime();
				$.get("mmap_week_ajax.php",{ y: year4,t : nowtime }, function(data){
					$("#week_cdto").children().remove();
					$("#week_cdto").append( data );
				});
			});
		});
		function toPage(thepage) {
			document.form1.page.value =  thepage;
			document.form1.csv.value="";
			document.form1.submit();
		}
		function chkWeek() {
			var weekid = $("#week_cd").val() ;
			if (weekid.length == 0){
				alert("週を選択してください");
				return false;
			 }
			return true;
		}
		function chkWeekto() {
			var weekid = $("#week_cdto").val() ;
			if (weekid.length == 0){
				alert("コピーの目標週を選択してください");
				return false;
			 }
			if (weekid <= $("#week_cd").val() )   {
				alert("コピーの目標週は結果の週 の未来日にしてください");
				return false;
			}
			return true;
		}
		</script>
		<link rel="stylesheet" type="text/css" href="./assets/styles/tablesorter.css" />
		<script type="text/javascript" src="./assets/scripts/tablesorter.js"></script>
	</head>
	<body id="">
{{$menu}}
{{$logout}}
		<div id="container"><div class="wrapper">
			<h2>マップグループマスター管理</h2>
			<ul class="submenu clearfix">
				<li><a href="mmapg_index.php">マップグループ情報一覧</a></li>
				<li>マップグループ情報更新</a></li>
				{{if !$isG7 }}<li><a href="mmapshop_import.php">CSV更新</a></li>{{ /if }}
				<li><a href="mmservice_index.php">サービスマップマスタ</a></li>
			</ul>
			<h3>マップグループ情報更新</h3>
			<form name="form1" id="form1" method="get" action="mmapshop_index.php" >
				<input type="hidden" name="page" />
				<table class="formTable searchTable">
					<tbody>
						<tr>
							<th><span>※</span>年度</th>
							<td>
{{ html_options id='year4' name='year4' options=$year4 selected=$forms.year4 }} 年{{ $err.year4 }}
							</td>
							<th><span>※</span>週名</th>
							<td>
{{ html_options id='week_cd' name='week_cd' options=$week  selected=$forms.week_cd }}{{ $err.week_cd }}
							</td>
						<tr>
							<th>区分</th>
							<td>
{{ html_options id='sort' name='sort' options=$map_sort selected=$forms.sort }}
							</td>
							<th>マップNO</th>
							<td>
								<input type="text" name="map_no_s" value="{{ $forms.map_no_s }}" />
							</td>
						</tr>
						<tr>
							<th>更新日</th>
							<td colspan="3">
								<input type="text" name="upd_f" class="text_date" value="{{ $forms.upd_f }}" /> ～
								<input type="text" name="upd_t" class="text_date" value="{{ $forms.upd_t }}" />
							</td>
						</tr>
					</tbody>
				</table>
				<p class="button" style="text-align:right">
					<button type="button" id="btn-reset"><span>クリア</span></button>
					<button type="button" id="btn_search" class="submit"><span>絞込検索</span></button>
				</p>
				<input type="hidden" name="search" value="1" />
				<input type="hidden" name="csv" />
				<input type="hidden" name="mapoperflg" />

			<hr>

			<p class="button btnleft">  <!-- <span>&nbsp;マップNO&nbsp; <input type="text" name="map_no"  value="{{ $forms.map_no}}" /></span>
			&nbsp;
			&nbsp;&nbsp;&nbsp;-->
			&nbsp;<button type="button" id="btn-map-add"><span>マップNO新規追加</span></button>
			{{ if ($errcopy)}} &nbsp;&nbsp;&nbsp;&nbsp;<font color=red>   {{  $errcopy|escape }} </font> {{ /if }}
			</p>

{{ if is_numeric($page.cnt) }}
{{ if $page.cnt > 0 }}
			<p class="message">{{ $page.cnt }}件の情報が見つかりました。</p>
			<p align="left">{{$pageing}}</p>
			<table id="search_result" class="sortable">
				<thead>
					<tr>
						<th><h3>区分</h3></th>
						<th><h3>マップNO</h3></th>
						<th><h3>店舗数</h3></th>
						<th><h3>地域新聞名</h3></th>
						<th><h3>更新日時</h3></th>
						<th><h3>操作</h3></th>
					</tr>
				</thead>
				<tbody>
{{ foreach from=$data key=k item=v name="member" }}
					<tr class="{{cycle values=odd,mod name='member'}}">
						<td>{{ $map_sort[$v.sort] }}</td>
						<td>{{ $v.map_no }}</td>
						<td align="right">{{ $v.shop_num|number_format }}</td>
						<td>{{ $v.media_name }}</td>
						<td class="center">{{ $v.u_time|date_format:"%Y-%m-%d %H:%M" }}</td>
						<td class="center"><a href="mmapshop_form.php?mm={{ $v.map_no }}&ww={{ $v.matrix_cd }}" class="tdbutton tdb2">更新</a></td>
					</tr>
{{ /foreach }}
				</tbody>
			</table>
			<!-- 		<td class="center"><input type="checkbox" name="delmapno[]" class="text" value="{{ $v.map_no }}" /> </td> -->
			<p align="right">{{$pageing}}</p>

		<p >   結果は　 {{ html_options id='year4to' name='year4to' options=$year4 selected=$forms.year4to }} 年
		{{ html_options id='week_cdto' name='week_cdto' options=$week  selected=$forms.week_cdto }}週へ<button type="button" id="btn-map-copy"><span>コピー</span></button>
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>&nbsp;マップNO&nbsp; <input type="text" name="map_no_del"  value="{{ $forms.map_no_del}}" /></span>
		&nbsp;<button type="button" id="btn-no-del"><span>削除</span></button>
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		{{ html_options id='sort_del' name='sort_del' options=$map_sort_del selected=$forms.sort_del }}&nbsp;<button type="button" id="btn-sort-del"><span>削除</span></button>
		{{ if ($errdel)}} &nbsp;&nbsp;&nbsp;&nbsp;<font color=red>   {{ $errdel }} </font> {{ /if }}

		</p>
{{ else }}
<p class="message">条件にマッチする情報は見つかりませんでした。</p>
{{ /if }}
{{ else }}
	<p class="message">ここに検索結果が表示されます。</p>
{{ /if }}
			</form>
		</div></div>
		{{ $footer }}
	</body>
</html>